# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=powerdevil
pkgver=5.25.3
pkgrel=0
pkgdesc="Manages the power consumption settings of a Plasma Shell"
# armhf blocked by extra-cmake-modules
# s390x and riscv64 blocked by polkit -> kio
arch="all !armhf !s390x !riscv64"
url="https://kde.org/plasma-desktop/"
license="GPL-2.0-or-later AND LGPL-2.0-or-later AND (LGPL-2.1-only OR LGPL-3.0-only)"
depends="upower"
depends_dev="
	bluez-qt-dev
	eudev-dev
	kactivities-dev
	kauth-dev
	kconfig-dev
	kcrash-dev
	kdbusaddons-dev
	kglobalaccel-dev
	ki18n-dev
	kidletime-dev
	kio-dev
	knotifications-dev
	knotifyconfig-dev
	kwayland-dev
	libkscreen-dev
	networkmanager-qt-dev
	plasma-workspace-dev
	qt5-qtbase-dev
	qt5-qtx11extras-dev
	solid-dev
	"
makedepends="$depends_dev
	extra-cmake-modules
	kdoctools-dev
	libcap-utils
	samurai
	"

case "$pkgver" in
	*.90*) _rel=unstable;;
	*) _rel=stable;;
esac
source="https://download.kde.org/$_rel/plasma/$pkgver/powerdevil-$pkgver.tar.xz"
subpackages="$pkgname-dev $pkgname-libs $pkgname-doc $pkgname-lang"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# We don't ship systemd
	rm -r "$pkgdir"/usr/lib/systemd

	# org_kde_powerdevil has CAP_WAKE_ALARM set and this breaks dbus
	# Remove CAP_WAKE_ALARM from org_kde_powerdevil to make it work again
	setcap -r "$pkgdir"/usr/lib/libexec/org_kde_powerdevil
}

sha512sums="
77c752579f03625172427833840fdf4c3b8c8ef8312f82d365dc846d1dd8ae0b64c81e2f48173c4aa153e90ca6b3beeac4f0ba7b0c60e9056de6307428964fa7  powerdevil-5.25.3.tar.xz
"
